package com.qunar.wan.common_api.model;

import com.qunar.wan.common_api.model.enums.Role;
import com.qunar.wan.common_api.serializer.DateSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;

import java.io.Serializable;
import java.util.Date;

/**
 * User: tongjie.yang Date: 11/25/13 Time: 6:46 PM
 */
public class User implements Serializable {
    private static final long serialVersionUID = -6513701657126768392L;
    private int id;
    private String userName;
    private Date loginTime;
    private String headImg;
    private Role role; // 数据库中用的int型
    private String email;
    private int totalScore;
    private boolean isFirstLogon;

    public int getTotalScore() {
        return totalScore;
    }

    public void setTotalScore(int totalScore) {
        this.totalScore = totalScore;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Role getRole() {
        return role;
    }

    public void setRole(Role role) {
        this.role = role;
    }

    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
    }

    @JsonSerialize(using = DateSerializer.class)
    public Date getLoginTime() {
        return loginTime;
    }

    public void setLoginTime(Date loginTime) {
        this.loginTime = loginTime;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public boolean getIsFirstLogon() {
        return isFirstLogon;
    }

    public void setIsFirstLogon(boolean isFirstLogon) {
        this.isFirstLogon = isFirstLogon;
    }

    @Override
    public String toString() {
        return "User{" + "id=" + id + ", userName='" + userName + '\'' + ", lastLoginTime='" + loginTime + '\''
                + ", headImg='" + headImg + '\'' + ", role=" + role.getMean() + ", email='" + email + '\'' + '}';
    }
}
